package com.t235.gc.biz.service.impl;

import com.t235.gc.entity.GarbageReadmeterRecord;
import com.t235.gc.dao.GarbageReadmeterRecordDao;
import com.t235.gc.biz.service.GarbageReadmeterRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 垃圾抄表记录表(GarbageReadmeterRecord)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:29
 */
@Service("garbageReadmeterRecordService")
public class GarbageReadmeterRecordServiceImpl implements GarbageReadmeterRecordService {
    @Resource
    private GarbageReadmeterRecordDao garbageReadmeterRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param recordid 主键
     * @return 实例对象
     */
    @Override
    public GarbageReadmeterRecord queryById(Long recordid) {
        return this.garbageReadmeterRecordDao.queryById(recordid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GarbageReadmeterRecord> queryAllByLimit(int offset, int limit) {
        return this.garbageReadmeterRecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param garbageReadmeterRecord 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageReadmeterRecord insert(GarbageReadmeterRecord garbageReadmeterRecord) {
        this.garbageReadmeterRecordDao.insert(garbageReadmeterRecord);
        return garbageReadmeterRecord;
    }

    /**
     * 修改数据
     *
     * @param garbageReadmeterRecord 实例对象
     * @return 实例对象
     */
    @Override
    public GarbageReadmeterRecord update(GarbageReadmeterRecord garbageReadmeterRecord) {
        this.garbageReadmeterRecordDao.update(garbageReadmeterRecord);
        return this.queryById(garbageReadmeterRecord.getRecordid());
    }

    /**
     * 通过主键删除数据
     *
     * @param recordid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long recordid) {
        return this.garbageReadmeterRecordDao.deleteById(recordid) > 0;
    }
}
